<template>
  <div>
    <el-table :data="userlist" style="width: 100%">
      <el-table-column
        :type="item.type"
        :width="item.width"
        :prop="item.propsVal"
        :label="item.labelName"
        v-for="(item, index) in cols"
        :key="index"
      >
        <template v-slot="{ row, index }" v-if="item.slot">
          <slot :name="item.slot" :row="row" :index="index"></slot>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageList.pagenum"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="pageList.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="Number(userlist.length)"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: "Mytable",
  props: {
    pageList: {
      type: Object,
      default: () => {},
    },
    userlist: {
      type: Array,
      default: () => [],
      
    },
    cols: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {};
  },
  methods: {
    // 分页
    handleSizeChange(val) {
      this.pageList.pagesize = val;
      this.$emit("handleSizeChange", this.pageList);
    },
    handleCurrentChange(val) {
      this.pageList.pagenum = val;
      this.$emit("handleCurrentChange", this.pageList);
    },
  },
  created() {},
  mounted() {},
  computed: {},
  watch: {},
};
</script>

<style lang="scss" scoped></style>
